fix(resource_github_organization_custom_properties): support bool default values - #3572
fix(resource_github_organization_custom_properties): support bool default values#3572secustor wants to merge 5 commits into
Conversation
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
|
Please mark clearly which issue this is going to resolve! |
I have been under the impression that the explanation above is clear enough, now there is also an example of the Terraform plan which will be generated on each plan and is not reconciled. |
|
@secustor I meant which issue number/URL. |
deiga
left a comment
There was a problem hiding this comment.
Thanks for the effort so far!
There was a problem hiding this comment.
Pull request overview
These provider review instructions are being used.
Fixes perpetual drift for boolean organization custom-property defaults by correctly reading and stringifying boolean API values.
Changes:
- Handles
true_falsedefaults during state refresh. - Adds regression coverage for empty follow-up plans.
- Documents unsupported
multi_selectdefaults.
Finding: The new test uses legacy assertion APIs instead of ConfigStateChecks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
github/resource_github_organization_custom_properties.go |
Reads boolean defaults correctly. |
github/resource_github_organization_custom_properties_test.go |
Adds regression coverage. |
templates/resources/organization_custom_properties.md.tmpl |
Documents default-value limitations. |
docs/resources/organization_custom_properties.md |
Updates generated documentation. |
Use ConfigStateChecks/ExpectKnownValue for the true_false default_value assertion instead of the legacy TestCheckResourceAttr Check, and note the multi_select limitation in the default_value schema Description. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| "default_value": { | ||
| Type: schema.TypeString, | ||
| Description: "The default value of the custom property", | ||
| Description: "The default value of the custom property. Not supported for multi_select properties.", |
There was a problem hiding this comment.
Would it make sense to add a validation to not use default with multi-select?
There was a problem hiding this comment.
My understanding is this would be breaking the setup for existing users which use the ignore_changes workaround 🤔
There was a problem hiding this comment.
I'm not sure that breaking the wrong way would be a problem. But if we want to be careful we should at least introduce a warning for this case
There was a problem hiding this comment.
What kind of warning do you want me to add?
I see different patterns here in the repo.
- Logging with
log.Printf("[WARN] ...") - Using diagnostics, though that would need more changes in that PR
- or simply in the docs
There was a problem hiding this comment.
diagnostics would be the best, let's go with that 🙏
Drop the redundant default_value state check (Terraform core already enforces consistency with config) and fold the drift regression guard into a PostApplyPostRefresh plan check on the apply step.
…context-aware CRUD Switches the resource to the CreateContext/ReadContext/UpdateContext/ DeleteContext and StateContext signatures used by most resources in the provider, so the CRUD functions receive a context and can return diagnostics instead of a bare error. Update now delegates to Create, which already upserts via PUT and reads the property back, removing a redundant second read.
…elect default_value GitHub returns the default value of a multi_select property as a list of strings, which cannot be represented by the string default_value attribute. The value is therefore not stored in state and every plan shows a change for default_value. Emit a warning diagnostic on create and update instead of rejecting the combination, so existing configurations relying on the ignore_changes workaround keep working.
|
I think #3234 should fix this, but if not this change would need to be made on top of the other PR. |
|
@secustor I don't think it's worth fixing this resource given that it's going to be replaced, I'd rather incentivise people to |
This is a minimal fix for users of default values and is intentionally tries not to reach the scope of #3234
Closes: #3580
Resolves infinite drift if when using
resource_github_organization_custom_propertiesofvalue_typetrue_falseanddefault_value.Infinite terraform plan:
Before the change?
customProperty.DefaultValueString()will return"", nillbecause of https://github.com/google/go-github/blob/a3951f514384b06cc428f394672020c14f7efd84/github/orgs_properties.go#L59This forces following workaround
After the change?
With this instead
customProperty.DefaultValueBool()is called and with that the return value istrue, nillwhich will then correctly set in the statePull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!